package test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.Vector;

public class ArraysExamples {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		primitivesArray();
		classArray();
		varArgs();
		vector();
	}

	private static void vector() {
		Vector v = new Vector();
		Stack s = new Stack();
		net.mindview.util.Stack ss = new net.mindview.util.Stack();

		ArrayList l = new ArrayList();
	}

	private static void varArgs() {
		printVarArgs(1);
		printVarArgs("abc");
		printVarArgs(1, "abc");
		printVarArgs(1, "abc", 1.1);
	}

	private static void printVarArgs(Object... args) {
		System.out.println(Arrays.toString(args));
	}

	private static void primitivesArray() {
		int[] a = { 1, 2, 4 };
		System.out.println(Arrays.toString(a));
		System.out.println(a);

		a = new int[10];
		System.out.println(Arrays.toString(a));
		System.out.println(a);
	}

	private static void classArray() {
		Integer[] a = { 1, 2, 3 };
		System.out.println(Arrays.toString(a));
		System.out.println(a);

		a = new Integer[10];
		System.out.println(Arrays.toString(a));
		System.out.println(a);

		a = new Integer[10];
		try {
			int b = a[0] + a[1];
		} catch (NullPointerException e) {
			e.printStackTrace();
		}
		for (int i = 0; i < a.length; ++i) {
			a[i] = 1;
		}
		System.out.println(Arrays.toString(a));
		System.out.println(a);
	}

}
